library(ggplot2)
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
library(DT)
SNPs = read.table("23andMe_complete.txt", header = TRUE, sep = "\t")
Exercise 1
ggplot(data = SNPs, aes(x= chromosome)) + geom_bar(fill="blue") + ggtitle("Count of SNPs in Each Chromosome") + labs(y= "SNP Count", x = "Chromosome")
Exercise 2
colorPal = c(
"--" = "Blue",
"A" = "Red",
"C" = "Red",
"G" = "Red",
"T" = "Red",
"AA" = "Green",
"AC" = "Green",
"AG" = "Green",
"AT" = "Green",
"CC" = "Green",
"CG" = "Green",
"CT" = "Green",
"DD" = "Blue",
"DI" = "Blue",
"GG" = "Green",
"GT" = "Green",
"II" = "Blue",
"D" = "Blue",
"I" = "Blue",
"TT" = "Green"
)
ggplot(data = SNPs, aes(fill = genotype, x= chromosome)) + geom_bar() + ggtitle("Genotype Contribution to Chromosome Count") + labs(y = "Count", x = "Chromosome ") + scale_fill_manual(values = colorPal)
ppi = 300
png("Exercise3_plot.png", width=6*ppi, height=6*ppi, res=ppi)
ggplot(data = SNPs, aes(chromosome, fill = genotype)) + geom_bar(position='dodge') + ggtitle("Individual Genotype Count Per Chromosome") + labs(x = "Chromosome", y = "Count")
dev.off()
## png
## 2
Exercise 3
Exercise 4
ggplot(data = SNPs, aes(chromosome, fill = genotype)) + geom_bar(position='dodge') + facet_wrap(~SNPs$genotype, ncol = 2) + ggtitle("Wrapped Graphs of Genotype Counts Per Chromosome") + labs(x ="Chromosome", y ="Count")
Exercise 5
ggplotly(
ggplot(data = SNPs, aes(chromosome, fill = genotype)) + geom_bar(position='dodge') + facet_wrap(~SNPs$genotype, ncol = 2) + ggtitle("Wrapped Graphs of Genotype Counts Per Chromosome (Plotly)") + labs(x ="Chromosome", y ="Count"), width = 1000, height = 1000)
Exercise 6
dataTable = SNPs[ which(SNPs$chromosome == 'Y'), ]
datatable(dataTable)
## Warning in instance$preRenderHook(instance): It seems your data is too big
## for client-side DataTables. You may consider server-side processing: https://
## rstudio.github.io/DT/server.html